package com.ruoyi.logisticscourier.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.logisticscourier.domain.Logisticscourier;
import com.ruoyi.logisticscourier.service.ILogisticscourierService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物流地址Controller
 * 
 * @author sqlstudent
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/logisticscourier/logisticscourier")
public class LogisticscourierController extends BaseController
{
    @Autowired
    private ILogisticscourierService logisticscourierService;

    /**
     * 查询物流地址列表
     */
    @PreAuthorize("@ss.hasPermi('logisticscourier:logisticscourier:list')")
    @GetMapping("/list")
    public TableDataInfo list(Logisticscourier logisticscourier)
    {
        startPage();
        List<Logisticscourier> list = logisticscourierService.selectLogisticscourierList(logisticscourier);
        return getDataTable(list);
    }

    /**
     * 导出物流地址列表
     */
    @PreAuthorize("@ss.hasPermi('logisticscourier:logisticscourier:export')")
    @Log(title = "物流地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Logisticscourier logisticscourier)
    {
        List<Logisticscourier> list = logisticscourierService.selectLogisticscourierList(logisticscourier);
        ExcelUtil<Logisticscourier> util = new ExcelUtil<Logisticscourier>(Logisticscourier.class);
        util.exportExcel(response, list, "物流地址数据");
    }

    /**
     * 获取物流地址详细信息
     */
    @PreAuthorize("@ss.hasPermi('logisticscourier:logisticscourier:query')")
    @GetMapping(value = "/{courierId}")
    public AjaxResult getInfo(@PathVariable("courierId") String courierId)
    {
        return success(logisticscourierService.selectLogisticscourierByCourierId(courierId));
    }

    /**
     * 新增物流地址
     */
    @PreAuthorize("@ss.hasPermi('logisticscourier:logisticscourier:add')")
    @Log(title = "物流地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Logisticscourier logisticscourier)
    {
        return toAjax(logisticscourierService.insertLogisticscourier(logisticscourier));
    }

    /**
     * 修改物流地址
     */
    @PreAuthorize("@ss.hasPermi('logisticscourier:logisticscourier:edit')")
    @Log(title = "物流地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Logisticscourier logisticscourier)
    {
        return toAjax(logisticscourierService.updateLogisticscourier(logisticscourier));
    }

    /**
     * 删除物流地址
     */
    @PreAuthorize("@ss.hasPermi('logisticscourier:logisticscourier:remove')")
    @Log(title = "物流地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{courierIds}")
    public AjaxResult remove(@PathVariable String[] courierIds)
    {
        return toAjax(logisticscourierService.deleteLogisticscourierByCourierIds(courierIds));
    }
}
